#ifndef WINGCOROUTINE_GLOBAL_H
#define WINGCOROUTINE_GLOBAL_H

#include <cstddef>
#include <functional>

#if defined(_MSC_VER) || defined(WIN64) || defined(_WIN64) ||                  \
    defined(__WIN64__) || defined(WIN32) || defined(_WIN32) ||                 \
    defined(__WIN32__) || defined(__NT__)
#define Q_DECL_EXPORT __declspec(dllexport)
#define Q_DECL_IMPORT __declspec(dllimport)
#else
#define Q_DECL_EXPORT __attribute__((visibility("default")))
#define Q_DECL_IMPORT __attribute__((visibility("default")))
#endif

#if defined(WINGCOROUTINE_LIBRARY)
#define WINGCOROUTINE_EXPORT Q_DECL_EXPORT
#else
#define WINGCOROUTINE_EXPORT Q_DECL_IMPORT
#endif

#if defined(OS_WINDOWS)
#define FASTCALL __attribute__((fastcall))
#else
#define FASTCALL
#endif

namespace Wing {

class WingCoroutine;

typedef void *ThreadParams;
typedef void (*FASTCALL ThreadFunctor)(WingCoroutine *, ThreadParams);
typedef size_t ThreadID;
typedef std::function<void(void)> CO_APC;

enum class ThreadState { DEAD, READY, RUNNING, SLEEP };

struct ThreadInfo {
  ThreadID id = 0;
  void *stack = nullptr;
  void *stackPC = nullptr;
  void *pc = nullptr;
  void *param = nullptr;
  ThreadFunctor functor = nullptr;
  ThreadState state = ThreadState::DEAD;
};

} // namespace Wing

#endif // WINGCOROUTINE_GLOBAL_H
